package com.myfoon.utils;


import com.myfoon.action.backing.system.CountryBean;
import com.myfoon.model.entity.CountryName;

import java.util.ArrayList;
import java.util.List;

import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;


public class CountryUtils {
    public CountryUtils() {
    }
    
    public List<SelectItem> getCountryList() {        
        FacesContext context = FacesContext.getCurrentInstance();
        String langStr = context.getViewRoot().getLocale().toString();
                
        CountryBean countryBean = new CountryBean();
        List<CountryName> ctrList = countryBean.findAllByLang(langStr);
        
        List<SelectItem> cList = new ArrayList<SelectItem>();            
        for (CountryName countryName : ctrList) {
            cList.add(new SelectItem(countryName.getCountry().getId(), countryName.getName()));
        }

        return cList;        
    }
}